/*
 * @Author: your name
 * @Date: 2020-05-13 09:44:07
 * @LastEditTime: 2020-05-13 09:56:25
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: /vue-cli4-multi/src/common/utils/extend/trigger.js
 */
/**
 * @see 扩展dispatchEvent事件语法,兼容IE
 */
window.sugar.trigger = function (element, event) {
  if (document.createEventObject) {
    // IE浏览器支持fireEvent方法
    const evt = document.createEventObject()
    evt.dispatchEvent = true
    return element.fireEvent('on' + event, evt)
  } else {
    // 其他标准浏览器使用dispatchEvent方法
    const evt = document.createEvent('HTMLEvents')
    evt.initEvent(event, true, true)
    evt.dispatchEvent = true
    return !element.dispatchEvent(evt)
  }
}
